
from collections import OrderedDict
correct_dict = OrderedDict([
    ('CART', [0.7452859160985198, 0.8491493151526319, 0.8182544069774584, 0.7839199066396413,
              0.8227995823352374, 0.8283274983109146, 0.8272833364043978, 0.8221853694490511, 0.8290645537743382]),
    ('AdaBoost', [0.7452244948099012, 0.8492721577298692, 0.8179473005343653, 0.794422946993428,
                  0.8149990786806707, 0.809901111725324, 0.832626988514219, 0.824212271973466, 0.821018364965297]),
    ('DPsAdaBoost(e=0.05)', [0.6122474049505559, 0.6264971439100793, 0.6344819114305018, 0.6483631226583134,
                             0.6491615994103557, 0.6422209937964498, 0.6389656654996622, 0.6446778453411952,
                             0.6446778453411952]),
    ('DPsAdaBoost(e=0.1)', [0.664578342853633, 0.673361587126098, 0.6854001596953504, 0.6882255389718076,
                            0.691358024691358, 0.699957005097967, 0.6915422885572139, 0.6916037098458325,
                            0.6941834039678152]),
    ('DPsAdaBoost(e=0.25)', [0.6717032123333948, 0.681100669492046, 0.6891468583010871, 0.6977458387076961,
                             0.6941834039678152, 0.7003255328296788, 0.6956575148946625, 0.7003869541182974,
                             0.6958417787605184]),
    ('DPsAdaBoost(e=0.5)', [0.7020453289110006, 0.7888950310177507, 0.7653092561881948, 0.7490940359928752,
                            0.7583072292856704, 0.7793747312818623, 0.7773478287574473, 0.7802346293225232,
                            0.7842884343713531]),
    ('DPsAdaBoost(e=0.75)', [0.7143295866347276, 0.8011792887414778, 0.7837356427737854, 0.7613782937166022,
                             0.774890977212702, 0.7855168601437258, 0.7957742153430379, 0.7783919906639641,
                             0.7904305632332166]),
    ('DPsAdaBoost(e=1)', [0.7452244948099012, 0.8492721577298692, 0.8180087218229839, 0.7953442663227075,
                          0.8111295374976967, 0.8210797862539156, 0.8334254652662613, 0.8240280081076101,
                          0.8324427246483631])])

import matplotlib.pyplot as plt

plt.rcParams['font.sans-serif'] = ['Times New Roman']  # 显示中文
plt.rcParams['axes.unicode_minus'] = False  # 显示负号

tree_depth_list = [2, 3, 4, 5, 6, 7, 8, 9, 10]


# 绘制决策树和adaboost的对比效果图
plt.figure(figsize=(7, 4.5), dpi=80)
for m, l in zip(correct_dict, ['o', 'v', '^', 's', '8', '*', 'D', 'H']):
    if m == 'CART':
        plt.plot(tree_depth_list, correct_dict[m], marker=l, alpha=.7, label=m)
    else:
        if 'e' in m:
            nmum = m.split('=')[1][:-1]

            plt.plot(tree_depth_list, correct_dict[m], marker=l, alpha=.7, label=r'%s($\epsilon=%s$)' % (m[:11], nmum))
        else:
            plt.plot(tree_depth_list, correct_dict[m], marker=l, alpha=.7, label=m)

plt.legend(loc=4, frameon=False, fontsize=7)
plt.xlabel('Depth', fontsize=7)
plt.ylabel('Accuracy(%)', fontsize=7)
plt.xticks(tree_depth_list, fontsize=7)
plt.show()